package com.meisupic.copyright.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.meisupic.copyright.common.AuthorizeRuleEnum;
import com.meisupic.copyright.common.WorksProcessDetailEnum;
import com.meisupic.copyright.common.WorksProcessEnum;
import com.meisupic.copyright.util.CategoryUtil;
import com.meisupic.copyright.util.DictionaryUtil;
import com.meisupic.copyright.util.StringUtil;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;

/**
 * creation wuxun
 *
 * @version V1.0
 * @Description: 版权登记作品对象
 * @date 2018/1/17 21:11
 */

@Data
public class CopyRightWorksRowVo implements Serializable {

  private static final long serialVersionUID = -4171159307927454581L;

  private Long id;

  /**
   * 作品名称.
   */
  private String worksFullName;

  /**
   * 作品类型
   */
  private String worksType;

  /**
   * 作者
   */
  private String author;

  /**
   * 创作完成国家
   */
  private String creationCountry;

  /**
   * 创作完成省份
   */
  private String creationProvince;

  /**
   * 创作完成城市
   */
  private String creationCity;

  /**
   * 创作日期
   */
  @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
  private Date creationDate;

  /**
   * 发表状态
   */
  private Integer publishStatus;

  /**
   * 首次发表国家
   */
  private String firstPublishCountry;

  /**
   * 首次发表省份
   */
  private String firstPublishProvince;

  /**
   * 首次发表城市
   */
  private String firstPublishCity;

  /**
   * 首次发表日期
   */
  @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
  private Date firstPublishDate;

  /**
   * 作品主要特点
   */
  private String mainFeatures;

  /**
   * 权利归属方式
   */
  private Integer rightOwnMode;

  /**
   * 权利取得方式
   */
  private Integer rightFetchMode;

  /**
   * 创作性质
   */
  private Integer creativeNature;


  /**
   * 分类id
   */
  private Integer categoryId;

  /**
   * 关键词.
   */
  private String keywords;

  /**
   * 授权规则
   */
  private AuthorizeRuleEnum authorizeRule;

  /**
   * 分成比例
   */
  private BigDecimal splitPercentage;

  /**
   * 授权证书名称
   */
  private String authorizeCertImageName;

  /**
   * 交易价格
   */
  private Integer price;


  /**
   * 图片名称
   */
  private String imageName;

  /**
   * eps图片名称
   */
  private String epsImageName;

  /**
   * 创作声明
   */
  private String creativeStatement;

  /**
   * 原创声明
   */
  private String originalStatement;

  /**
   * 合作创作声明
   */
  private String cooperationStatement;

  /**
   * 法人创作声明
   */
  private String LegalCreationStatement;

  /**
   * 作品给版权保护中心的唯一标识符
   */
  private String resId;

  /**
   * dci码
   */
  private String dciCode;

  private String dna;

  /**
   * dci信息查询地址
   */
  private String dciUrl;


  /**
   * 证书公布时间
   */
  private Date promulgateDate;


  /**
   * 审核状态
   */
  private WorksProcessEnum worksProcess;

  /**
   * 审核详细状态
   */
  private WorksProcessDetailEnum worksProcessDetail;

  private String createor;

  /**
   * 评分
   */
  private Integer score;

  /**
   * 用途
   */
  private Integer uses;


  /**
   * 创建时间
   */
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Date createTime;

  /**
   * 修改时间
   */
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Date modifyTime;

  private String worksTypeName;

  private String workCategroyName;

  private String publishStatusName;

  private String creativeNatureName;

  private String authorizeRuleDesc;

  private String worksProcessDesc;

  private String worksProcessDetailDesc;

  private String imageUrl;

  private String certFileName;

  private String certImgUrl;

  private String authCertFileUrl;

  private String failReason;

  private String huabanThumbnailUrl;

  private Integer isOnSale;

  private String mobile;

  private String rCode;

  private Integer rCodeStatus;

  private String certificateUrl;

  public String getWorksTypeName() {
    return DictionaryUtil.getDicNameByValue(this.getWorksType(), "worktype");
  }

  public String getWorkCategroyName() {
    return CategoryUtil.getCategoryName(this.getCategoryId());
  }

  public String getPublishStatusName() {
    return DictionaryUtil.getDicNameByValue(this.getPublishStatus().toString(), "publishstatus");
  }

  public String getCreativeNatureName() {
    return DictionaryUtil.getDicNameByValue(this.getCreativeNature().toString(), "creativeNature");
  }

  public String getAuthorizeRuleDesc() {
    return this.getAuthorizeRule().getDesc();
  }

  public String getWorksProcessDesc() {
    return this.getWorksProcess().getDesc();
  }

  public String getWorksProcessDetailDesc() {
    return this.getWorksProcessDetail().getDesc();
  }

  public String getImageUrl() {
    if (!StringUtil.isEmpty(this.getHuabanThumbnailUrl())) {
      return this.getHuabanThumbnailUrl();
    }
    return this.getImageName() + "?x-oss-process=style/large_style_h";
  }

  public String getCertImgUrl() {
    if (StringUtil.isEmpty(getCertFileName())) {
      return "";
    }
    return "http://meisudci.oss-cn-beijing.aliyuncs.com/certificate/" + this.getCertFileName()
        .replace("pdf", "jpg");
  }

}
